package com.googlecode.rjm.model.journal;

import java.text.ParseException;
import java.util.Date;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;

import com.googlecode.rjm.util.DateUtil;

@Entity
@DiscriminatorValue(value = "attr#due_date")
public class DueDateJournalDetail extends JournalDetail<Date> {

	private static final long serialVersionUID = 1L;

	@Override
	public Date getTypedValue() throws ParseException {
		String value = getValue();
		if(value == null) {
			return null;
		}
		
		return DateUtil.format.parse(value);
	}

	@Override
	public Date getOldTypedValue() throws ParseException {
		String oldValue = getOldValue();
		if(oldValue == null) {
			return null;
		}
		
		return DateUtil.format.parse(oldValue);
	}

}
